<template>
    <div id="hongbaoActivity" style="width:90%;">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="150px">
            <div style="text-align:right">
              <el-button @click="goback()" size="mini" type="primary" style="margin-right:10px">返回</el-button>
            </div>
            <!--基本信息-->
            <el-divider content-position="left">基本信息</el-divider>
            <el-form-item label="活动名称：" prop="activityName">
              <el-input
                    type="textarea"
                    v-model="ruleForm.activityName"
                    :disabled="disabledFlag"
                    placeholder="请输入活动名称"
                    maxlength="30"
                    show-word-limit
                    style="width:250px;"
                ></el-input>
            </el-form-item>
            <el-form-item label="　有效期：" prop="runTimeRange"
              v-if="activityDetail == null || activityDetail.runStatus == '1'">
              <el-date-picker
                v-model="ruleForm.runTimeRange"
                type="daterange"
                align="right"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                value-format="yyyy-MM-dd"
                :picker-options="pickerOptions"
                :clearable="false"
                :disabled="disabledFlag"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label="　有效期：" prop="endDate"
              v-if="activityDetail != null && activityDetail.runStatus != '1'">
              <el-date-picker
                v-model="ruleForm.beginDate"
                value-format="yyyy-MM-dd"
                type="date"
                :disabled="true"
              ></el-date-picker>
              至
              <el-date-picker
                v-model="ruleForm.endDate"
                type="date"
                value-format="yyyy-MM-dd"
                :clearable="false"
              ></el-date-picker>
            </el-form-item>
            <!--发放规则-->
            <el-divider content-position="left">酒红包发放规则配置</el-divider>
            <el-form-item label="　每笔订单满：" prop="orderAmountLimit">
              <el-input
                v-model="ruleForm.orderAmountLimit"
                type="number"
                oninput="value=value.replace(/[^0-9.]/g,'')"
                class="input_edit"
                v-on:blur="orderAmountLimitCheck()"
                style="text-align-last:right;width:300px;"
                placeholder="仅限线上支付订单"
                :disabled="disabledFlag"
              >
                <template slot="append">元</template>
              </el-input>
            </el-form-item>
            <!--
            <el-form-item label="酒红包有效期：" prop="validDay">
              <el-input
                v-model="ruleForm.validDay"
                type="number"
                oninput="value=value.replace(/[^0-9]/g,'')"
                class="input_edit"
                v-on:blur="validDayCheck()"
                style="text-align-last:right;width:300px;"
                placeholder="以活动开始时间计算天数"
                :disabled="disabledFlag"
              >
                <template slot="append">天</template>
              </el-input>
            </el-form-item>
            -->
            <!--
            <el-form-item label="酒红包清零时间：" prop="validTime">
              <el-date-picker
                v-model="ruleForm.validTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                :clearable="false"
              ></el-date-picker>
            </el-form-item>
            -->
            <!--酒红包列表-->
            <el-form-item label="" prop="hongbaoCount">
              <div id="hongbaoActivityTable">
                <el-table
                    ref="hongbaoTable"
                    :data="relationList"
                    border
                    style="width:100%;"
                    v-loading="loading"
                    :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
                >
                    <el-table-column
                        prop="packetName"
                        sortable
                        column-key="packetName"
                        label="酒红包名称"
                        align="center"
                    ></el-table-column>
                    <el-table-column prop="probabilityPercent" sortable label="获得概率" align="center">
                        <template slot-scope="scope">
                          <el-input
                              type="number"
                              :min="1"
                              :max="100"
                              oninput="value=value.replace(/[^0-9]/g,'')"
                              v-model="scope.row.probabilityPercent"
                              style="width:150px; text-align-last:right;"
                              v-on:blur="probabilityCheck(scope.row,scope.$index)"
                              :disabled="disabledFlag"
                          ><template slot="append">%</template>
                          </el-input>
                        </template>
                    </el-table-column>
                    <el-table-column prop="lowerLimit" sortable label="毫升数" align="center">
                        <template slot-scope="scope">
                          <div>
                            <el-input
                                type="number"
                                :min="1"
                                oninput="value=value.replace(/[^0-9]/g,'')"
                                v-model="scope.row.lowerLimit"
                                style="width:40%; text-align-last:right;"
                                v-on:blur="lowerLimitCheck(scope.row,scope.$index)"
                                :disabled="disabledFlag"
                            ></el-input>
                            ~
                            <el-input
                                type="number"
                                :min="1"
                                oninput="value=value.replace(/[^0-9]/g,'')"
                                v-model="scope.row.upLimit"
                                style="width:40%; text-align-last:right;"
                                v-on:blur="upLimitCheck(scope.row,scope.$index)"
                                :disabled="disabledFlag"
                            ></el-input>
                          </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center" v-if="!disabledFlag">
                      <template slot-scope="scope">
                        <el-button size="mini" @click="deleteRedPacketItem(scope.row,scope.$index)" type="text">删除</el-button>
                      </template>
                    </el-table-column>
                </el-table>
              </div>
              <el-button type="primary" @click="showRedPacketDialog()" icon="el-icon-plus" size="mini" style="margin:20px 0 20px 0"
                v-if="!disabledFlag">添加酒红包</el-button>
            </el-form-item>
            <!--规则配置-->
            <el-divider content-position="left">酒红包转赠规则配置</el-divider>
            <el-form-item label="单个酒红包不超过" prop="donateLimitMace">
              <!--
              <el-input
                  v-model="ruleForm.tale"
                  type="number"
                  oninput="value=value.replace(/[^0-9]/g,'')"
                  class="input_edit edit_append_first"
                  v-on:blur="taleCheck()"
                  style="text-align-last:right;width:150px;"
                  :disabled="disabledFlag"
                >
                <template slot="append">两</template>
              </el-input><el-input
                  v-model="ruleForm.mace"
                  type="number"
                  oninput="value=value.replace(/[^0-9]/g,'')"
                  class="input_edit edit_append_middle"
                  v-on:blur="maceCheck()"
                  style="text-align-last:right;width:150px;"
                  :disabled="disabledFlag"
                >
                <template slot="append">钱</template>
              </el-input>
              -->
              <el-input
                  v-model="ruleForm.donateLimitMace"
                  type="number"
                  oninput="value=value.replace(/[^0-9]/g,'')"
                  class="input_edit"
                  v-on:blur="mlCheck()"
                  style="text-align-last:right;width:300px;"
                  :disabled="disabledFlag"
                >
                <template slot="append">毫升</template>
              </el-input>
            </el-form-item>
            <!--发布状态-->
            <el-divider></el-divider>
            <el-form-item label="酒红包规则描述：" prop="remark">
                <el-input
                    type="textarea"
                    v-model="ruleForm.remark"
                    :disabled="disabledFlag"
                    placeholder="请输入规则描述"
                    maxlength="60"
                    show-word-limit
                    :autosize="{ minRows: 4 }"
                    style="width:650px;"
                ></el-input>
            </el-form-item>
            <el-form-item label="发布状态：">
                <el-radio-group v-model="ruleForm.publishStatus" :disabled="disabledFlag">
                    <el-radio-button label="0">不发布</el-radio-button>
                    <el-radio-button label="1">发布</el-radio-button>
                </el-radio-group>
            </el-form-item>

            <el-form-item style="width:100%;text-align:center">
                <el-button @click="resetForm('ruleForm')" v-show="!this.disabledFlag">取 消</el-button>
                <el-button type="primary" @click="submitForm('ruleForm')" v-show="!this.disabledFlag" :loading="submitLoading">保 存</el-button>
            </el-form-item>
        </el-form>

        <!--添加活动酒红包弹窗-->
        <el-dialog title="添加活动酒红包" :visible.sync="insertRedPacketDialogVisible" width="60%">
          <div>
            <el-form :inline="true" :model="formInline2" class="demo-form-inline">
              <el-row :span="24">
                <el-col :span="24">
                  <el-form-item label="酒红包名称：">
                    <el-input v-model="formInline2.packetName" clearable placeholder style="width:200px"></el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="search2()" size="mini" icon="el-icon-search">查询</el-button>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="kong2()" size="mini" icon="el-icon-delete">清空</el-button>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
            <div class="table2">
              <el-table ref="table2"
                  tooltip-effect="dark"
                  style="width: 100%"
                  v-loading="loading2"
                  :data="chooseRedPacketList"
                  @selection-change="handleSelectionChange2"
                  border
                  :header-cell-style="{background:'#eef1f6',color:'#606266'}"
              >
                <el-table-column type="selection" width="60" align="center" fixed disabled></el-table-column>
                <el-table-column prop="packetName" label="酒红包名称" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column prop="remark" label="酒红包描述" align="center" show-overflow-tooltip></el-table-column>
              </el-table>
              <div class="block" style="margin-top:22px;overflow:hidden">
                <el-pagination
                  @size-change="handleSizeChange2"
                  @current-change="handleCurrentChange2"
                  :page-sizes="[5, 10, 20, 30, 50, 100, 150, 200]"
                  :current-page="listQuery2.current"
                  :page-size="listQuery2.size"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="total2"
                ></el-pagination>
              </div>
              <el-row>
                <el-col :span="24" style="text-align: center;margin-top: 30px">
                  <el-button 
                    type="info"
                    @click="closeRedPacketDialog()" 
                    size="mini"
                  >取 消</el-button>
                  <el-button
                    type="primary"
                    @click="insertRedPacket()"
                    size="mini"
                  >确 认</el-button>
                </el-col>
              </el-row>
            </div>
          </div>
        </el-dialog>

        
    </div>
</template>
<script>
import {
  queryRedPacketActivityDetail,
  queryChooseRedPacketList,
  saveRedPacketActivity,
} from "@/api/redPacketActivity";

const curDateStr = function (){
  var curDate = new Date();
  var year = curDate.getFullYear();
  var month = curDate.getMonth() + 1;
  month = month > 9 ? month : "0" + month;
  var date = curDate.getDate();
  date = date > 9 ? date : "0" + date;
  return year + "-" + month + "-" + date;
}

const isMoney = function(rule, value, callback) {
  const reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
  if (!value) {
    return callback(new Error("金额不能为空"));
  } else if (!reg.test(value)) {
    return callback(new Error("金额格式错误"));
  } else if (value <= 0) {
    return callback(new Error("金额不能小于等于0"));
  } else {
    callback();
  }
};

export default {
  data() {
    return {
      disabledFlag: false,
      insertRedPacketDialogVisible: false,//挑选酒红包弹窗
      activityDetail: null,//活动详细
      ruleForm: {
        uuid: null,
        activityName: "",
        runTimeRange: [curDateStr(), curDateStr()],
        beginDate: curDateStr(),
        endDate: curDateStr(),
        orderAmountLimit: null,
        validDay: null,
        validTime: null,
        tale: null,
        mace: null,
        donateLimitMace: null,
        remark: null,
        publishStatus: "0",
        hongbaoCount: null
      },
      rules: {
        activityName: [
          { required: true, message: "请输入买赠活动名称", trigger: "blur" }
        ],
        runTimeRange: [
          { required: true, message: "请选择买赠活动有效期", trigger: "blur" }
        ],
        endDate: [
          { required: true, message: "请输入结束时间", trigger: "blur" },
          { validator: this.endDateCheck, trigger: "blur" }
        ],
        /*
        validTime: [
          { required: true, message: "请输入酒红包清零时间", trigger: "blur" },
          { validator: this.validTimeCheck, trigger: "blur" }
        ],
        */
        orderAmountLimit: [
          { required: true, message: "请输入单笔订单最小额度限制", trigger: "blur" },
          { validator: isMoney, trigger: "blur" }
        ],
        donateLimitMace: [
          { required: true, message: "请输入转赠单个红包面额", trigger: "blur"}
        ],
        hongbaoCount: [
          { required: true, message: "请添加酒红包", trigger: "blur" }
        ]
      },
      loading: true,
      loading2: true,
      submitLoading: false,
      total: 0,
      total2: 0,
      listQuery: {
        current: 1,
        size: 100
      },
      listQuery2: {
        current: 1,
        size: 5
      },
      sort: "",
      order: "",
      relationList: [],//红包列表
      chooseRedPacketList: [],//挑选酒红包列表
      batchSelRedPackets: [],//记录挑选多选红包
      formInline2: {
        packetName: ""
      },//查询2
      pickerOptions: {
        shortcuts: [
          {
            text: "未来3天",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              end.setTime(start.getTime() + 3600 * 1000 * 24 * 3);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "未来一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              end.setTime(start.getTime() + 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "未来一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              end.setTime(start.getTime() + 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          }
        ],
        disabledDate(time){
          return time.getTime() < Date.now()-8.64e7   //如果当天可选，就不用减8.64e7
        }
      },
    };
  },
  mounted() {
    this.disabledFlag = this.$route.params.flag;
    var v = this.$route.params.edit;
    if (v) {
      this.queryRedPacketActivityDetail(v);
    }else{
      this.loading = false;
    }
  },
  methods: {
    //查询活动详细
    queryRedPacketActivityDetail(v){
      let data = {uuid: v.uuid};
      // 修改，回显值
      this.ruleForm.uuid = v.uuid;
      this.ruleForm.activityName = v.activityName;
      this.ruleForm.runTimeRange = [v.beginDate, v.endDate];
      this.ruleForm.beginDate = v.beginDate;
      this.ruleForm.endDate = v.endDate;
      this.ruleForm.orderAmountLimit = v.orderAmountLimit;
      //this.ruleForm.validDay = v.validDay;
      //this.ruleForm.validTime = v.validTime;
      //this.ruleForm.tale = v.tale;
      //this.ruleForm.mace = v.mace;
      this.ruleForm.donateLimitMace = v.donateLimitMace;
      this.ruleForm.remark = v.remark;
      this.ruleForm.publishStatus = v.publishStatus;
      queryRedPacketActivityDetail(data).then(res => {
        if(res.code == 1 && res.result != null){
          this.loading = false;
          this.activityDetail = res.result;
          this.relationList = res.result.relationList;
          this.ruleForm.hongbaoCount = this.relationList.length  == 0 ? null : this.relationList.length;
        }
      });
    },
    //删除酒红包行
    deleteRedPacketItem(row, index){
      this.relationList.splice(index, 1);
      this.ruleForm.hongbaoCount = this.relationList.length  == 0 ? null : this.relationList.length;
    },
    
    /******酒红包弹窗方法********/
    //显示挑选酒红包弹窗
    showRedPacketDialog(){
      this.queryChooseRedPacketList();
      this.insertRedPacketDialogVisible = true;
    },
    //关闭挑选酒红包弹窗
    closeRedPacketDialog(){
      this.insertRedPacketDialogVisible = false;
      this.chooseRedPacketList = [];
    },
    //挑选酒红包列表
    queryChooseRedPacketList(){
      let includeRedPackets = [];
      this.relationList.forEach((item, index) => {          
        includeRedPackets.push(item.packetId);
      });
      let data = {
        current: this.listQuery2.current,
        size: this.listQuery2.size,
        condition: {
          packetList: includeRedPackets.length == 0 ? null : includeRedPackets,
          packetName: this.formInline2.packetName.trim(),
          status:"1"
        },
        ascs: [],
        descs: []
      };
      queryChooseRedPacketList(data).then(res => {
        this.loading2 = false;
        this.chooseRedPacketList = res.records;
        this.total2 = res.total;
      });
    },
    handleSizeChange2(val) {
      this.listQuery2.size = val;
      this.queryChooseRedPacketList();
    },
    handleCurrentChange2(val) {
      this.listQuery2.current = val;
      this.queryChooseRedPacketList();
    },
    //查询酒红包
    search2(){
      this.listQuery2.current = 1;
      this.queryChooseRedPacketList();
    },
    //重置酒红包
    kong2(){
      this.formInline2.packetName = "";
    },
    //监听选择器
    handleSelectionChange2(val) {
      this.batchSelRedPackets = val;
    },
    //添加酒红包
    insertRedPacket(){
      if(this.batchSelRedPackets.length == 0){
         this.$message({
            showClose: true,
            message: "请先挑选纳入活动的酒红包",
            type: "info"
          });
          return false;
      }
      this.relationList.forEach((item, index) => {          
        this.relationList[index].probabilityPercent = null;
      });
      for (let index = 0; index < this.batchSelRedPackets.length; index++) {
        let row = this.batchSelRedPackets[index];
        this.relationList.splice(0, 0, row);
      }
      this.ruleForm.hongbaoCount = this.relationList.length  == 0 ? null : this.relationList.length;
      this.$refs['ruleForm'].validateField("hongbaoCount");
      this.closeRedPacketDialog();
    },
    
    //返回
    goback() {
      this.$router.go("-1");
    },
    //取消
    resetForm(formName) {
      this.$refs[formName].resetFields();
      this.$router.push("hongbaoActivityManage");
    },
    //保存活动
    submitForm(formName){
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if(this.relationList == null || this.relationList.length == 0){
            this.$message({showClose: true, message: "酒红包列表不能为空",type: "info"});
            return;
          }
          let allProbability = 0;
          for(let index = 0; index < this.relationList.length; index++){
            if(this.relationList[index].probabilityPercent == null){
              this.$message({showClose: true, message: "酒红包获得概率不能为空",type: "info"});
              return;
            }else{
              allProbability  += parseFloat(this.relationList[index].probabilityPercent);
              this.relationList[index].probability = parseFloat(this.relationList[index].probabilityPercent) / 100.00;
            }
            if(this.relationList[index].lowerLimit == null || this.relationList[index].upLimit == null){
              this.$message({showClose: true, message: "酒红包面额上下限不能为空",type: "info"});
              return;
            }
          }
          if(allProbability != 100){
            this.$message({showClose: true, message: "所有酒红包概率总和不等于100",type: "info"});
            return;
          }
          let beginDate = null;
          let endDate = null;
          if(this.activityDetail != null && this.activityDetail.runStatus != "1"){
            beginDate = this.activityDetail.beginDate;
            endDate = this.ruleForm.endDate;
          }else{
            beginDate = this.ruleForm.runTimeRange[0];
            endDate = this.ruleForm.runTimeRange[1];
          }
          let data = {
            uuid: this.ruleForm.uuid,
            activityName: this.ruleForm.activityName,
            beginDate: beginDate,
            endDate: endDate,
            orderAmountLimit: this.ruleForm.orderAmountLimit,
            //validDay: this.ruleForm.validDay,
            //validTime: this.ruleForm.validTime,
            donateLimitMace: this.ruleForm.donateLimitMace,
            remark: this.ruleForm.remark,
            publishStatus: this.ruleForm.publishStatus,
            relationList: this.relationList
          };
          this.submitLoading = true;
          saveRedPacketActivity(data).then(res => {
            if(res.code == 1){
                this.$message({
                showClose: true,
                message: res.message,
                type: "success"
              });
              //this.submitLoading = false;
              this.$router.push("hongbaoActivityManage");
            }else{
              this.submitLoading = false;
              this.$message({
                showClose: true,
                message: res.message,
                type: "error"
              });
            }
          });
        } else {
          return false;
        }
      });
    },
    //两钱转换为钱
    getDonateLimitMace(){
      let total = 0;
      let tale = this.ruleForm.tale;
      if (tale != null && !isNaN(tale) && parseInt(tale) > 0) {
        total += parseInt(tale) * 10;
      }
      let mace = this.ruleForm.mace;
      if (mace != null && !isNaN(mace) && parseInt(mace) > 0) {
        total += parseInt(mace);
      }
      this.ruleForm.donateLimitMace = total == 0 ? null : total;
      this.ruleForm.tale = parseInt(this.ruleForm.donateLimitMace / 10) == 0 ? null : parseInt(this.ruleForm.donateLimitMace / 10);
      this.ruleForm.mace = this.ruleForm.donateLimitMace % 10 == 0 ? null : this.ruleForm.donateLimitMace % 10;
    },
    //单笔最小校验
    orderAmountLimitCheck(){
      let val = this.ruleForm.orderAmountLimit;
      if (val != null && !isNaN(val)) {
        this.ruleForm.orderAmountLimit = parseFloat(val).toFixed(2);
      }
      return true;
    },
    //有效期校验
    validDayCheck(){
      let val = this.ruleForm.validDay;
      if (val != null && !isNaN(val) && parseInt(val) > 0) {
        this.ruleForm.validDay = parseInt(val);
      }else{
        this.ruleForm.validDay = null;
      }
      return true;
    },
    //有效期校验
    mlCheck(){
      let val = this.ruleForm.donateLimitMace;
      if (val != null && !isNaN(val) && parseInt(val) > 0) {
        this.ruleForm.donateLimitMace = parseInt(val);
      }else{
        this.ruleForm.donateLimitMace = null;
      }
      return true;
    },
    //两校验
    taleCheck(){
      let val = this.ruleForm.tale;
      if (val != null && !isNaN(val) && parseInt(val) > 0) {
        this.ruleForm.tale = parseInt(val);
      }else{
        this.ruleForm.tale = null;
      }
      this.getDonateLimitMace();
      return true;
    },
    //钱校验
    maceCheck(){
      let val = this.ruleForm.mace;
      if (val != null && !isNaN(val) && parseInt(val) > 0) {
        this.ruleForm.mace = parseInt(val);
      }else{
        this.ruleForm.mace = null;
      }
      this.getDonateLimitMace();
      return true;
    },
    //概率校验
    probabilityCheck(row, index) {
      let val = row.probabilityPercent;
      if (val === null || val === undefined || val === "") {
        this.$message({showClose: true, message: "填入数量不能为空",type: "info"});
        val = null;
      } else if (isNaN(val)){
        this.$message({showClose: true, message: "填入数量格式错误",type: "info"});
        val = null;
      } else if (val <= 0 || val > 100){
        this.$message({showClose: true, message: "填入数量应在0-100之间",type: "info"});
        val = null;
      }
      this.relationList[index].probabilityPercent = val != null ? parseInt(val) : null;
      return true;
    },
    //最低面额校验
    lowerLimitCheck(row, index) {
      let val = row.lowerLimit;
      let val2 = row.upLimit;
      if (val === null || val === undefined || val === "") {
        this.$message({showClose: true, message: "填入数量不能为空",type: "info"});
        val = null;
      } else if (isNaN(val)){
        this.$message({showClose: true, message: "填入数量格式错误",type: "info"});
        val = null;
      } else if (val <= 0){
        this.$message({showClose: true, message: "填入数量应大于0",type: "info"});
        val = null;
      } else if (val2 != null && !isNaN(val2) && val > val2){
        this.$message({showClose: true, message: "填入数量应小于等于最高值",type: "info"});
        val = null;
      }
      this.relationList[index].lowerLimit = val != null ? parseInt(val) : null;
      return true;
    },
    //最高面额校验
    upLimitCheck(row, index) {
      let val = row.upLimit;
      let val2 = row.lowerLimit;
      if (val === null || val === undefined || val === "") {
        this.$message({showClose: true, message: "填入数量不能为空",type: "info"});
        val = null;
      } else if (isNaN(val)){
        this.$message({showClose: true, message: "填入数量格式错误",type: "info"});
        val = null;
      } else if (val <= 0){
        this.$message({showClose: true, message: "填入数量应大于0",type: "info"});
        val = null;
      } else if (val2 != null && !isNaN(val2) && val < val2){
        this.$message({showClose: true, message: "填入数量应大于等于最低值",type: "info"});
        val = null;
      }
      this.relationList[index].upLimit = val != null ? parseInt(val) : null;
      return true;
    },
    //结束日期校验
    endDateCheck(rule, value, callback) {
      if (!value) {
        return callback(new Error("结束日期不能为空"));
      } else if (value < this.ruleForm.beginDate) {
        return callback(new Error("结束日期不能小于开始日期"));
      } else {
        callback();
      }
    },
    //酒红包清零校验
    validTimeCheck(rule, value, callback) {
      let beginDate = this.ruleForm.runTimeRange[0];
      if (!value) {
        return callback(new Error("酒红包清零时间不能为空"));
      } else if (value.substr(0,10) < beginDate) {
        return callback(new Error("酒红包清零时间不能小于开始日期"));
      } else {
        callback();
      }
    }
  },//其他
  computed: {
    
  }
};
</script>
<style scoped>
#hongbaoActivity /deep/ .el-dialog__body{
  padding-top:0px;
}
#hongbaoActivity /deep/ input.el-input__inner[type='number']{
  padding:0;
}
#hongbaoActivity /deep/ .edit_append_first .el-input-group__append{
  border-right:none;
  border-radius:0;
}
#hongbaoActivity /deep/ .edit_append_middle .el-input__inner{
  border-radius:0;
}
</style>
